package com.example.prison.mapper;

import com.example.prison.entity.CarTrafficRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author jiang
* @description 针对表【car_traffic_record】的数据库操作Mapper
* @createDate 2024-06-03 11:33:54
* @Entity com.example.prison.entity.CarTrafficRecord
*/
@Mapper
public interface CarTrafficRecordMapper extends BaseMapper<CarTrafficRecord> {

//    @Select("select * from car_traffic_record order by id desc")
    @Select("<script>select * from car_traffic_record " +
            " <where> " +
            " <if test=\"number != null and number != ''\">and number like concat('%',#{number},'%') </if> " +
            " <if test=\"beginDate != null and beginDate != ''\">and time &gt;= #{beginDate} </if> " +
            " <if test=\"endDate != null and endDate != ''\">and time &lt;= #{endDate} </if> " +
            " </where> " +
            "order by id desc</script>")
    List<CarTrafficRecord> get(String number, String beginDate, String endDate);

    @Insert("insert into car_traffic_record(number,time,sn,describe) " +
            "values (#{number},#{time},#{sn},#{describe})")
    int add(CarTrafficRecord record);

    @Delete("<script>delete from car_traffic_record where id in <foreach collection=\"ids\" item=\"item\" open=\"(\" separator=\",\" close=\")\">#{item} </foreach> </script>")
    void deleting(@Param("ids") Integer[] ids);

    @Select("select * from car_traffic_record where id=#{id}")
    CarTrafficRecord getById(@Param("id") Integer id);


}




